#ifndef __RENDER_THREAD_H__
#define __RENDER_THREAD_H__

#include "utils/basethread.h"

typedef void (Delegater::*OnRenderContextReadyFunc)();
typedef void (Delegater::*OnRenderSceneFunc)();
typedef void (Delegater::*OnRenderSizeChangedFunc)(Size size);

class RenderThread : public BaseThread
{
public:
	RenderThread();
	~RenderThread();

	void Init(HDC hDC);
	void SetWinSize(Size size);

private:
	void SetupRC();
	void SetDCPixelFormat();
	bool CheckStates();
	void RenderScene();
	void ThreadFunc();

public:
	Event<OnRenderContextReadyFunc> OnSetupRC;
	Event<OnRenderSceneFunc> OnRenderScene;
	Event<OnRenderSizeChangedFunc> OnRenderChangeSize;

private:
	HGLRC m_hRC;
	HDC m_hDC;
	int m_nWidth;
	int m_nHeight;

	bool m_bResize;
};

#endif